//替换所有的问号
class Solution {
public:
    string modifyString(string s) {
        int n = s.size();
        for (size_t i = 0; i < n; ++i) {
            if (s[i] == '?') {
                for (char ch = 'a'; ch < 'z'; ++ch) {
                    if ((i == 0 || ch != s[i - 1]) &&
                        (i == n - 1 || ch != s[i + 1])) {
                        s[i] = ch;
                        break;
                    }
                }
            }
        }
        return s;
    }
};

//提莫攻击
class Solution {
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int n = timeSeries.size();
        int ret = 0;
        for(size_t i = 0 ; i < n-1 ; ++i)
        {
            int a = timeSeries[i];
            int b = timeSeries[i+1];
            if(b-a < duration)ret += (b-a);
            else ret += duration;
        }
        ret += duration;
        return ret;
    }
};

//Z字形变换
class Solution {
public:
    string convert(string s, int numRows) {
        int n = s.size();
        vector<vector<char>> vv(numRows,vector<char>(n));
        int num = 0, row = 0 , col = 0;
        while(num < s.size())
        {
            for(; num < s.size() && row < numRows ; ++row)
            {
                vv[row][col] = s[num];
                ++num;
            }
            if(row > 1)--row;
            for(; num < s.size() && row > 0 ;)
            {
                vv[--row][++col] = s[num];
                ++num;
            }
            ++row;
        }
        string ret;
        for(auto& v : vv)
        {
            for(auto& e : v)
            {
                if(e != '\0')ret += e;
            }
        }
        return ret;
    }
};













